#ifndef DIRECTORY_H
#define DIRECTORY_H

#include <string>
#include <list>

#include "file.h"

/**
 * Directory is a helper static class that allows the user deal with 
 * directories.
 */
class Directory
{
  public:

    /**
     * Destructor. Doesn't do much really.
     */
    ~Directory();

    /**
     * Given a directory path, returns true if the path correspond to a 
     * existing readable directory, else it returns false.
     */
    static bool exists(const std::string& dirPath);

    /**
     * Given a directory path, Creates it directory non-recursively. It
     * returns true if it succeeds. If the directory already exists or if
     * it fails to create the directory for some reason, it returns false.
     */
    static bool mkdir(const std::string& dirPath);

    /**
     * Counts the number of elements a directory (specified by its directory
     * path) has. It can filter so that it only counts Files, Directories 
     * and/or Dot Files.
     */
    static int count(const std::string& dirPath,
        int filter = File::Directories|File::Files);

    /**
     * Counts the number of elements a directory (specified by its directory
     * path) has. It can filter so that it only counts Files, Directories 
     * and/or Dot Files.
     *
     * @returns whether the counting is zero or not.
     */
    static bool isEmpty(const std::string& dirPath,
        int filter = File::Directories|File::Files);

    /**
     * Lists the elements a directory (specified by its directory path) has.
     * It can filter so that it only counts Files, Directories  and/or Dot 
     * Files.
     *
     * @returns a vector containing the names of the files/directories 
     * listed.
     */
    static std::list<std::string> listDir(const std::string& dirPath,
        int filter = File::Directories|File::Files,std::string end="");

  protected:
    /**
     * Constructor hidden as this is a static class.
     */
    Directory();
};

#endif
